# function removes returns that occur within holdoff periods of the 
# previous occurance
# caution: function is slow

returnHoldoff <- function(returns, holdoff=10) {
  retdf <- returns[1,] # retdf contains filtered returns
  for (i in 2:dim(returns)[1]) {
    indx <- rownames(returns[i,])
    previndx <- rownames(returns[i-1,])
    split <- strsplit(indx, " ", fixed=TRUE)
    prevsplit <- strsplit(previndx, " ", fixed=TRUE)
    if (length(split[[1]]) == 1) {
      if (as.double(difftime(as.POSIXct(split[[1]][1]), as.POSIXct(prevsplit[[1]][1]), units="days")) > holdoff) {
        retdf <- rbind(retdf, returns[i,])
      }
    } else if (length(split[[1]]) == 2) {
      # symbol names equal?
      if (split[[1]][2] ==prevsplit[[1]][2]) {
        if (as.double(difftime(as.POSIXct(split[[1]][1]), as.POSIXct(prevsplit[[1]][1]), units="days")) > holdoff) {        
          retdf <- rbind(retdf, returns[i,])
        }
      }
    }
  }
  return(retdf)
}